//
//  IGPaintingDetailOperateCell.m
//  jingdongfang
//
//  Created by boectoswteam on 2018/5/3.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "IGPaintingDetailOperateCell.h"

@interface IGPaintingDetailOperateCell ()

@end

@implementation IGPaintingDetailOperateCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        [self awakeFromNib];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
   
    _followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_followBtn setBackgroundImage:[UIImage imageNamed:@"addFollow"] forState:UIControlStateNormal];
//    _followBtn.backgroundColor = [UIColor yellowColor];
    _followBtn.tag = 101;
    [self addSubview:_followBtn];
    _followLabel = [[UILabel alloc]init];
    _followLabel.backgroundColor = [UIColor whiteColor];
    _followLabel.text = @"2222";
    _followLabel.font = [UIFont systemFontOfSize:11];
    _followLabel.textColor = [UIColor c4Color];
    [_followBtn addSubview:_followLabel];
    
    _addToPaintingListBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_addToPaintingListBtn setBackgroundImage:[UIImage imageNamed:@"addPaintingList"] forState:UIControlStateNormal];
    _addToPaintingListBtn.tag = 102;
    [self addSubview:_addToPaintingListBtn];
    
    _voicePlayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_voicePlayBtn setBackgroundImage:[UIImage imageNamed:@"voicePlay"] forState:UIControlStateNormal];
    _voicePlayBtn.tag = 103;
    [self addSubview:_voicePlayBtn];
    
    _commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_commentBtn setBackgroundImage:[UIImage imageNamed:@"showComments"] forState:UIControlStateNormal];
//    _commentBtn.backgroundColor = [UIColor yellowColor];
    _commentBtn.tag = 104;
    _commentLabel = [[UILabel alloc]init];
    _commentLabel.backgroundColor = [UIColor whiteColor];
    _commentLabel.text = @"2222";
    _commentLabel.font = [UIFont systemFontOfSize:11];
    _commentLabel.textColor = [UIColor c4Color];
    [_commentBtn addSubview:_commentLabel];
    [self addSubview:_commentBtn];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    NSNumber *itemWidth = [NSNumber numberWithInt:90];
    NSUInteger btnWidth = 90;
    
    if (!1) {
        
        NSUInteger currentWidth = (KSCREENWIDTH -btnWidth*4)/4;
        [_followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2);
        }];
        
        [_followLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@40);
            make.top.offset(20);
            make.left.offset(50);
            make.height.equalTo(@14);
        }];
        
        [_addToPaintingListBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2+currentWidth+btnWidth);
        }];
        [_voicePlayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2+currentWidth*2+2*btnWidth);
        }];
        
        [_commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2+currentWidth*3+btnWidth*3);
        }];
        [_commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@40);
            make.top.offset(20);
            make.left.offset(50);
            make.height.equalTo(@14);
        }];
    } else {
        NSUInteger currentWidth = (KSCREENWIDTH -btnWidth*3)/3;
        [_followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2);
        }];
        [_followLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@50);
            make.top.offset(20);
            make.left.offset(50);
            make.height.equalTo(@14);
        }];
        [_addToPaintingListBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2+currentWidth+btnWidth);
        }];
        
        [_commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(itemWidth);
            make.top.offset(0);
            make.height.equalTo(@50);
            make.left.offset(currentWidth/2+currentWidth*2+btnWidth*2);
        }];
        [_commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@50);
            make.top.offset(20);
            make.left.offset(50);
            make.height.equalTo(@14);
        }];
    }
}

-(void)setModel:(IGWorkDetailModel *)model{
    if (model) {
        if ([model.ifLove  isEqualToString:@"1"]) {
            [_followBtn setImage:[UIImage imageNamed:@"followed"] forState:UIControlStateNormal];
            _followLabel.backgroundColor = [UIColor clearColor];
        } else {
            [_followBtn setImage:[UIImage imageNamed:@"addFollow"] forState:UIControlStateNormal];
            _followLabel.backgroundColor = [UIColor whiteColor];
        }
        NSInteger loveNum = [model.loveNum integerValue];
        NSInteger commentNum = [model.commentNum integerValue];
        
//        if () {
//            <#statements#>
//        }
        
        _followLabel.text = loveNum>=0?model.loveNum:@"0";
        _commentLabel.text = commentNum>=0?model.commentNum:@"0";
    }
}


//-(NSString *)getNumberStringWithString:(NSString *)number{
//    NSInteger numInteger = [number integerValue];
//    if (numInteger>=10000) {
//        NSInteger asdsa =  numInteger/10000
//    }
//}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
